/*
 * Created on 2004.8.12
 */
package lv.solcraft.replication.common;

/**
 * Class for holding various replication constants.
 * 
 * @author Ilgvars
 */
public abstract class ReplicationConst {

    /** operation type INSERT */
    public static final String TYPE_INSERT = "I";

    /** operation type UPDATE */
    public static final String TYPE_UPDATE = "U";

    /** operation type DELETE */
    public static final String TYPE_DELETE = "D";

    public static final String STATE_NEW = "N";

    public static final String STATE_COMMITED = "C";

    public static final String STATE_IGNORED = "I";

    public static final String STATE_ERROR = "E";

    public static final int EVENT_TYPE_DEBUG = 1;

    public static final int EVENT_TYPE_INFO = 2;

    public static final int EVENT_TYPE_WARN = 3;

    public static final int EVENT_TYPE_ERROR = 4;

    public static final String getEventTypeAsString(int eventType) {
        if (eventType == EVENT_TYPE_DEBUG) {
            return "DEBUG";
        } else if (eventType == EVENT_TYPE_INFO) {
            return "INFO";
        } else if (eventType == EVENT_TYPE_WARN) {
            return "WARN";
        } else if (eventType == EVENT_TYPE_ERROR) {
            return "ERROR";
        } else {
            throw new RuntimeException("Unknown event type " + eventType);
        }
    }

    public static final int getEventTypeAsInt(String eventType) {
        if ("DEBUG".equals(eventType)) {
            return EVENT_TYPE_DEBUG;
        } else if ("INFO".equals(eventType)) {
            return EVENT_TYPE_INFO;
        } else if ("WARN".equals(eventType)) {
            return EVENT_TYPE_WARN;
        } else if ("ERROR".equals(eventType)) {
            return EVENT_TYPE_ERROR;
        } else {
            throw new RuntimeException("Unknown event type " + eventType);
        }
    }
}
